/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-11-24 22:18:20
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.risk.entity;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.joysuch.wwyt.bp.entity.BpDepart;
import com.joysuch.wwyt.core.entity.BaseUser;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import com.joysuch.wwyt.dataperm.enums.DataPermissionFilterType;
import com.joysuch.wwyt.risk.entity.dto.UserBean;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "WWYT_RISK_POINT")
@SQLDelete(sql = "update WWYT_RISK_POINT set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_RISK_POINT set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class RiskPoint implements java.io.Serializable {

    // columns START
    // ID
    private java.lang.Long id;

    @NotNull(field = "名称")
    // 名称
    private java.lang.String name;
    // 编号
    private java.lang.String code;
    // 描述
    private java.lang.String description;
    // 状态
    private java.lang.Integer state;
    // 风险等级
    private java.lang.Integer riskLevel;
    // 容易发生的事故类型 ->主要后果
    private String accidentType;
    // SCL评估状态
    private java.lang.Integer sclEvaluationState;
    // JHA评估状态
    private java.lang.Integer jhaEvaluationState;
    // 创建人
    private java.lang.Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private java.lang.Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private java.lang.String deleteFlag;
    // 组织机构代码
    private java.lang.String orgCode;
    // 租户
    // 租户
    private java.lang.Long tenentId;
    // columns END

    // 上一次评估时间
    private Date lastEvaluationTime;
    @NotNull(field = "风险点类型")
    private String type;
    private String standard;
    //存在的主要危险(有害)因素  ->危害分析
    private String unstandardSituationConsequence;
    private String subType;

    // 关联模块
    private String relatedModule;
    // 关联模块ID
    private Long relatedModuleId;
    // 是否共享风险点:null风险点,1风险点库
    private Integer shared;

    //44不显示
    private Integer showState;

    //固有风险等级
    private Integer stableRiskLevel;
    //控制风险等级
    private Integer controlRiskLevel;

    //风险要素(人，物，环，管)
    private String riskFactor;
    //安全警示标志
    private String safeWarnMark;
    //辨识人员
    private Long identifyUserId;
    private String identifyUserStr;

    private String identifyUserCodes;

    private List<UserBean> identifyUserIdList;

    //责任人员
    private Long dutyUserId;
    //审核状态
    private Byte status;
    @ApiModelProperty("审核意见")
    private String auditOpinion;
    @ApiModelProperty("审核人员")
    private Long auditUserId;
    @ApiModelProperty("审核时间")
    private LocalDateTime auditDateTime;

    @ApiModelProperty("风险点评估值")
    private String pointEvaluationValue;
    @ApiModelProperty("下一次评估时间")
    private Date nextEvaluationDate;

    @ApiModelProperty("风险分区中心点经度")
    private String x;

    @ApiModelProperty("风险分区中心点纬度")
    private String y;

    @ApiModelProperty("所有方法评估人id(固有,控制)")
    private String evaluatorIdJson;

    //风险要素(人，物，环，管)
    private List<String> riskFactors;

    @ApiModelProperty("应急处置措施")
    private String emergencyHandleMeasures;
    @ApiModelProperty("备注")
    private String remark;
    @ApiModelProperty("所属岗位")
    private Long dutyJobId;
    @ApiModelProperty("度量值")
    private String measureValue;

    @ApiModelProperty("点位")
    private String points;

    @ApiModelProperty("楼层id")
    private Long floorId;

    @ApiModelProperty("建筑id")
    private String buildingId;

    @ApiModelProperty("位置信息")
    private String location;

    @ApiModelProperty("签到方式(0：人员定位，1：刷卡签到，2：不签到，3：二维码签到)")
    private Integer signInMethod;

    @ApiModelProperty("是否区分楼层(1：开启，0：关闭)")
    private Integer distinguishFloor;

    @ApiModelProperty("nfc的CODE")
    private String nfc;

    @ApiModelProperty("实时风险等级")
    private Integer realTimeRiskLevel;

    @ApiModelProperty("风险点的中心点位")
    private String centerPoint;

    public String getCenterPoint() {
        return centerPoint;
    }

    public void setCenterPoint(String centerPoint) {
        this.centerPoint = centerPoint;
    }

    public Integer getSignInMethod() {
        return signInMethod;
    }

    public void setSignInMethod(Integer signInMethod) {
        this.signInMethod = signInMethod;
    }

    public Integer getDistinguishFloor() {
        return distinguishFloor;
    }

    public void setDistinguishFloor(Integer distinguishFloor) {
        this.distinguishFloor = distinguishFloor;
    }

    public String getNfc() {
        return nfc;
    }

    public void setNfc(String nfc) {
        this.nfc = nfc;
    }

    public String getPoints() {
        return points;
    }

    public void setPoints(String points) {
        this.points = points;
    }

    public Long getFloorId() {
        return floorId;
    }

    public void setFloorId(Long floorId) {
        this.floorId = floorId;
    }

    public String getBuildingId() {
        return buildingId;
    }

    public void setBuildingId(String buildingId) {
        this.buildingId = buildingId;
    }

    @Column(name = "real_time_risk_level")
    public Integer getRealTimeRiskLevel() {
        return realTimeRiskLevel;
    }

    public void setRealTimeRiskLevel(Integer realTimeRiskLevel) {
        this.realTimeRiskLevel = realTimeRiskLevel;
    }

    @Transient
    public List<String> getRiskFactors() {
        return riskFactors;
    }

    public void setRiskFactors(List<String> riskFactors) {
        this.riskFactors = riskFactors;
    }

    @Column(name = "evaluator_id_json")
    public String getEvaluatorIdJson() {
        return evaluatorIdJson;
    }

    public void setEvaluatorIdJson(String evaluatorIdJson) {
        this.evaluatorIdJson = evaluatorIdJson;
    }

    @Column(name = "x")
    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }

    @Column(name = "y")
    public String getY() {
        return y;
    }

    public void setY(String y) {
        this.y = y;
    }

    @Column(name = "point_evaluation_value")
    public String getPointEvaluationValue() {
        return pointEvaluationValue;
    }

    public void setPointEvaluationValue(String pointEvaluationValue) {
        this.pointEvaluationValue = pointEvaluationValue;
    }

    @Column(name = "next_evaluation_date")
    public Date getNextEvaluationDate() {
        return nextEvaluationDate;
    }

    public void setNextEvaluationDate(Date nextEvaluationDate) {
        this.nextEvaluationDate = nextEvaluationDate;
    }

    public String getAuditOpinion() {
        return auditOpinion;
    }

    public void setAuditOpinion(String auditOpinion) {
        this.auditOpinion = auditOpinion;
    }

    public Long getAuditUserId() {
        return auditUserId;
    }

    public void setAuditUserId(Long auditUserId) {
        this.auditUserId = auditUserId;
    }

    public LocalDateTime getAuditDateTime() {
        return auditDateTime;
    }

    public void setAuditDateTime(LocalDateTime auditDateTime) {
        this.auditDateTime = auditDateTime;
    }

    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    public String getRiskFactor() {
        return riskFactor;
    }

    public void setRiskFactor(String riskFactor) {
        this.riskFactor = riskFactor;
    }

    public String getSafeWarnMark() {
        return safeWarnMark;
    }

    public void setSafeWarnMark(String safeWarnMark) {
        this.safeWarnMark = safeWarnMark;
    }

    public Long getIdentifyUserId() {
        return identifyUserId;
    }

    public void setIdentifyUserId(Long identifyUserId) {
        this.identifyUserId = identifyUserId;
    }

    @Column(name = "identify_user_str")
    public String getIdentifyUserStr() {
        return identifyUserStr;
    }

    public void setIdentifyUserStr(String identifyUserStr) {
        this.identifyUserStr = identifyUserStr;
    }

    @Column(name = "identify_user_codes")
    public String getIdentifyUserCodes() {
        return identifyUserCodes;
    }

    public void setIdentifyUserCodes(String identifyUserCodes) {
        this.identifyUserCodes = identifyUserCodes;
    }

    @Transient
    public List<UserBean> getIdentifyUserIdList() {
        return identifyUserIdList;
    }

    public void setIdentifyUserIdList(List<UserBean> identifyUserIdList) {
        this.identifyUserIdList = identifyUserIdList;
    }

    public Long getDutyUserId() {
        return dutyUserId;
    }

    public void setDutyUserId(Long dutyUserId) {
        this.dutyUserId = dutyUserId;
    }

    @Column(name = "stable_risk_level")
    public Integer getStableRiskLevel() {
        return stableRiskLevel;
    }

    public void setStableRiskLevel(Integer stableRiskLevel) {
        this.stableRiskLevel = stableRiskLevel;
    }

    @Column(name = "control_risk_level")
    public Integer getControlRiskLevel() {
        return controlRiskLevel;
    }

    public void setControlRiskLevel(Integer controlRiskLevel) {
        this.controlRiskLevel = controlRiskLevel;
    }

    @Column(name = "show_state")
    public Integer getShowState() {
        return showState;
    }

    public void setShowState(Integer showState) {
        this.showState = showState;
    }

    public void setId(java.lang.Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public java.lang.Long getId() {
        return this.id;
    }

    @Column(name = "SHARED")
    public Integer getShared() {
        return shared;
    }

    public void setShared(Integer shared) {
        this.shared = shared;
    }

    @Column(name = "ACCIDENT_TYPE", length = 500)
    public String getAccidentType() {
        return accidentType;
    }

    public void setAccidentType(String accidentType) {
        this.accidentType = accidentType;
    }

    @Column(name = "NAME", length = 50)
    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String value) {
        this.name = value;
    }

    @Column(name = "CODE", length = 10)
    public java.lang.String getCode() {
        return this.code;
    }

    public void setCode(java.lang.String value) {
        this.code = value;
    }

    @Column(name = "DESCRIPTION", length = 500)
    public java.lang.String getDescription() {
        return this.description;
    }

    public void setDescription(java.lang.String value) {
        this.description = value;
    }

    @Column(name = "STATE")
    public java.lang.Integer getState() {
        return this.state;
    }

    public void setState(java.lang.Integer value) {
        this.state = value;
    }

    @Column(name = "RISK_LEVEL")
    public java.lang.Integer getRiskLevel() {
        return this.riskLevel;
    }

    public void setRiskLevel(java.lang.Integer value) {
        this.riskLevel = value;
    }

    @Column(name = "SCL_EVALUATION_STATE")
    public java.lang.Integer getSclEvaluationState() {
        return this.sclEvaluationState;
    }

    public void setSclEvaluationState(java.lang.Integer value) {
        this.sclEvaluationState = value;
    }

    @Column(name = "JHA_EVALUATION_STATE")
    public java.lang.Integer getJhaEvaluationState() {
        return this.jhaEvaluationState;
    }

    public void setJhaEvaluationState(java.lang.Integer value) {
        this.jhaEvaluationState = value;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public java.lang.Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(java.lang.Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public java.lang.Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(java.lang.Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public java.lang.String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(java.lang.String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public java.lang.String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(java.lang.String value) {
        this.orgCode = value;
    }

    @Column(name = "LAST_EVALUATION_TIME")
    public Date getLastEvaluationTime() {
        return lastEvaluationTime;
    }

    public void setLastEvaluationTime(Date lastEvaluationTime) {
        this.lastEvaluationTime = lastEvaluationTime;
    }

    @Column(name = "SUB_TYPE", length = 4)
    public String getSubType() {
        return subType;
    }

    public void setSubType(String subType) {
        this.subType = subType;
    }

    @Column(name = "TENENT_ID")
    public java.lang.Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(java.lang.Long value) {
        this.tenentId = value;
    }

    @DataPermissionField(type = DataPermissionFilterType.JOIN_TABLE,
            sqlColumn = "risk_district_id", joinInfo = {"wwyt_risk_district", "id",
            "responsible_dept"})
    private RiskDistrict riskDistrict;

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "RISK_DISTRICT_ID")
    public RiskDistrict getRiskDistrict() {
        return this.riskDistrict;
    }

    public void setRiskDistrict(RiskDistrict riskDistrict) {
        this.riskDistrict = riskDistrict;
    }

    @Column(name = "CONTROL_LEVEL_ID")
    private Long controlLevelId;

    // private BaseTypeGroupItem controlLevel;
    //
    // @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
    // @JoinColumn(name = "CONTROL_LEVEL_ID")
    // public BaseTypeGroupItem getControlLevel() {
    // return this.controlLevel;
    // }
    //
    // public void setControlLevel(BaseTypeGroupItem baseTypeGroupItem) {
    // this.controlLevel = baseTypeGroupItem;
    // }

    public Long getControlLevelId() {
        return controlLevelId;
    }

    public void setControlLevelId(Long controlLevelId) {
        this.controlLevelId = controlLevelId;
    }

    private BpDepart responsibleDepart;

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "RESPONSIBLE_DEPART_ID")
    public BpDepart getResponsibleDepart() {
        return this.responsibleDepart;
    }

    public void setResponsibleDepart(BpDepart bpDepart) {
        this.responsibleDepart = bpDepart;
    }

    private BaseUser responsibleUser;

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "RESPONSIBLE_PERSON_ID")
    public BaseUser getResponsibleUser() {
        return responsibleUser;
    }

    public void setResponsibleUser(BaseUser baseUser) {
        this.responsibleUser = baseUser;
    }

    private RiskPointEvaluationScl riskPointEvaluationScl;

    @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "LAST_SCL_EVALUATION_ID")
    public RiskPointEvaluationScl getRiskPointEvaluationScl() {
        return this.riskPointEvaluationScl;
    }

    public void setRiskPointEvaluationScl(RiskPointEvaluationScl riskPointEvaluationScl) {
        this.riskPointEvaluationScl = riskPointEvaluationScl;
    }

    private RiskPointEvaluationJha riskPointEvaluationJha;

    @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "LAST_JHA_EVALUATION_ID")
    public RiskPointEvaluationJha getRiskPointEvaluationJha() {
        return this.riskPointEvaluationJha;
    }

    public void setRiskPointEvaluationJha(RiskPointEvaluationJha riskPointEvaluationJha) {
        this.riskPointEvaluationJha = riskPointEvaluationJha;
    }

    @Column(name = "TYPE", length = 10)
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Column(name = "STANDARD", length = 1000)
    public String getStandard() {
        return standard;
    }

    @Column(name = "RELATED_MODULE", length = 20)
    public String getRelatedModule() {
        return relatedModule;
    }

    public void setRelatedModule(String relatedModule) {
        this.relatedModule = relatedModule;
    }

    @Column(name = "RELATED_MODULE_ID")
    public Long getRelatedModuleId() {
        return relatedModuleId;
    }

    public void setRelatedModuleId(Long relatedModuleId) {
        this.relatedModuleId = relatedModuleId;
    }

    public void setStandard(String standard) {
        this.standard = standard;
    }

    @Column(name = "unstandard_situation_consequence", length = 1000)
    public String getUnstandardSituationConsequence() {
        return unstandardSituationConsequence;
    }

    public void setUnstandardSituationConsequence(String unstandardSituationConsequence) {
        this.unstandardSituationConsequence = unstandardSituationConsequence;
    }

    @Column(name = "emergency_handle_measures", length = 512)
    public String getEmergencyHandleMeasures() {
        return emergencyHandleMeasures;
    }

    public void setEmergencyHandleMeasures(String emergencyHandleMeasures) {
        this.emergencyHandleMeasures = emergencyHandleMeasures;
    }

    @Column(name = "remark", length = 512)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Column(name = "duty_job_id")
    public Long getDutyJobId() {
        return dutyJobId;
    }

    public void setDutyJobId(Long dutyDepartId) {
        this.dutyJobId = dutyDepartId;
    }

    @Column(name = "measure_value", length = 64)
    public String getMeasureValue() {
        return measureValue;
    }

    public void setMeasureValue(String measureValue) {
        this.measureValue = measureValue;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Transient
    public boolean isSharedPoint() {
        return shared != null && shared == 1;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
                .append("code", getCode()).append("description", getDescription()).append("state", getState())
                .append("riskLevel", getRiskLevel()).append("sclEvaluationState", getSclEvaluationState())
                .append("jhaEvaluationState", getJhaEvaluationState()).append("createBy", getCreateBy())
                .append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime()).append("deleteFlag", getDeleteFlag())
                .append("orgCode", getOrgCode()).append("tenentId", getTenentId())
                .append("stableRiskLevel", getStableRiskLevel()).append("controlRiskLevel", getControlRiskLevel())
                .append("points", getPoints())
                .append("floorId", getFloorId())
                .append("buildingId", getBuildingId())
                .append("signInMethod", getSignInMethod())
                .append("distinguishFloor", getDistinguishFloor())
                .append("nfc", getNfc()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof RiskPoint == false)
            return false;
        if (this == obj)
            return true;
        RiskPoint other = (RiskPoint) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
